{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 18 集合"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.【判断】Python中符号{}仅用在集合这一数据类型中。（ ）\n",
    "\n",
    "A.√  \n",
    "B.×"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：B"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.【填空】请写出下列代码的运行结果：（ ）  \n",
    "`\n",
    "set1 = {1,3,5,7}\n",
    "set2 = {1,3,7,5,3}\n",
    "print(set1 == set2)`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：True"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.【填空】语句set(\"datascience\")的结果是：（ ）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：{'a', 'c', 'd', 'e', 'i', 'n', 's', 't'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4.【选择】下列关于集合的说法错误的是：（ ）\n",
    "\n",
    "A.集合具有互异性，定义集合时不允许出现相同的元素\n",
    "B.集合具有确定性，可以用in来判断元素是否在集合内\n",
    "C.集合具有无序性，集合没办法进行排序\n",
    "D.集合具有运算性，支持并交差等运算"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：A"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5.【填空】请写出下列代码的运行结果：（ ）  \n",
    "`\n",
    "set1 = {2,4,5,6,7,8}\n",
    "set2 = {1,4,5,6,9}\n",
    "print(set1 ^set2)`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：{1, 2, 7, 8, 9}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "6.【选择】执行下列Python语句后的结果是：（ ）  \n",
    "`\n",
    "set1 = {2,3}\n",
    "se2 = frozenset(set1)\n",
    "set1.add(5)\n",
    "set2.remove(2)\n",
    "print(set1)\n",
    "print(set2)\n",
    "`\n",
    "\n",
    "A.{2,3,5}、{2,3}\n",
    "B.{2,3,5}、{3}\n",
    "C.{2,3}、{3}\n",
    "D.报错"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "7.【选择】在Python中对数据进行去重处理，一般会借助下列哪种数据类型？（ ）\n",
    "\n",
    "A.列表  \n",
    "B.元组  \n",
    "C.集合  \n",
    "D.字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：C"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
